package com.jdz.controller.backend;

import com.jdz.common.ServerResponse;
import com.jdz.pojo.GroupPrivilege;
import com.jdz.service.IPrivilegeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/manage/privilege")
public class PrivilegeServiceManageController {

    @Autowired
    IPrivilegeService iPrivilegeService;

    /**
     * 列出所有权限
     * @return
     */
    @RequestMapping(value = "list_all.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse listAll() {
        return iPrivilegeService.listAll();
    }

    /**
     * 列出本分组拥有的权限的id
     * @param groupno
     * @return
     */
    @RequestMapping(value = "list.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse list(Integer groupno){
        return iPrivilegeService.list(groupno);
    }

    /**
     * 删除权限分组关联
     * @param permno
     * @param groupno
     * @return
     */
    @RequestMapping(value = "delete_and.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse deleteAnd(Integer permno,Integer groupno){
        return iPrivilegeService.deleteAnd(permno,groupno);
    }

    /**
     * 添加分组权限分组关联
     * @param groupPrivilegeForm
     * @return
     */
    @RequestMapping(value = "add_and.do",method = RequestMethod.POST)
    @ResponseBody
    public ServerResponse  addAnd(GroupPrivilege groupPrivilegeForm){
        return iPrivilegeService.addAnd(groupPrivilegeForm);
    }

}
